package 第二轮工作.上海工程技术大学;

import com.alibaba.excel.EasyExcel;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import 第二轮工作.东北石油大学.DBSuBean;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class SHGu {
    public static void main(String[] args) throws IOException {
        SHGuBean shGuBean;
        List<SHGuBean> shGuBeans = new ArrayList<>();
        Connection connect = Jsoup.connect("https://seee.sues.edu.cn/11008/list.htm");
        Document post = connect.post();
        for (Element colNewsCon : post.getElementsByClass("col_news_con")) {
            for (Element articleTitle : colNewsCon.getElementsByClass("Article_Title")) {
                shGuBean = new SHGuBean();
//                System.out.println(articleTitle.text());
                shGuBean.setT_name(articleTitle.text());
//                System.out.println(articleTitle.getElementsByTag("a").attr("href"));
                Connection connect1 = Jsoup.connect("https://seee.sues.edu.cn" + articleTitle.getElementsByTag("a").attr("href"));
                Document post1 = connect1.post();
//                System.out.println(post1.getElementsByClass("infobox").text());
                shGuBean.setInfo(post1.getElementsByClass("infobox").text());
                shGuBeans.add(shGuBean);
            }

        }
        EasyExcel.write("src/SHGu.xlsx", SHGuBean.class).sheet("user").doWrite(shGuBeans);

    }
}
